package com.ttloner.mybatis.controller;

import com.ttloner.mybatis.mapper.UserMapper;
import com.ttloner.mybatis.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author TTLoner
 * @date 2021/7/17 13:40
 * @description
 */
@RestController
public class TestController {
    @Autowired
    private UserMapper userMapper;

    @GetMapping("selectById")
    public User Test(){
        return userMapper.selectById(2);
    }

    @GetMapping("seletAll")
    public List<User> Test1(){
        return userMapper.selectAll();
    }

    @GetMapping("delete")
    public String Test2(){
        userMapper.delete(5);
        return "删除成功";
    }

    @GetMapping("insert")
    public List<User> insert(User user){
        userMapper.insert(user);
        return userMapper.selectAll();
    }

}
